package com.brzjomo.secretiveworld.world.dimension;

import com.brzjomo.secretiveworld.world.dimension.fogcolor.FogColor;
import com.brzjomo.secretiveworld.world.dimension.generator.ModChunkGenerator;
import com.brzjomo.secretiveworld.world.dimension.provider.TestDimBiomeProvider;
import com.brzjomo.secretiveworld.world.dimension.setting.ModBiomeProviderSettings;
import com.brzjomo.secretiveworld.world.dimension.setting.ModDimGenSettings;

import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.dimension.Dimension;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraftforge.client.IRenderHandler;

public class TestDimension extends Dimension {

	public TestDimension(World worldIn, DimensionType typeIn) {
		super(worldIn, typeIn, 0.0F);
	}

	@Override
	public ChunkGenerator<?> createChunkGenerator() {
		return new ModChunkGenerator(world,
				new TestDimBiomeProvider(new ModBiomeProviderSettings(this.world.getWorldInfo())),
				new ModDimGenSettings());
	}

	@Override
	public boolean isSurfaceWorld() {
		return true;
	}

	@Override
	public int getActualHeight() {
		return 256;
	}

	@Override
	public boolean canRespawnHere() {
		return true;
	}

	@Override
	public BlockPos findSpawn(ChunkPos chunkPosIn, boolean checkValid) {
		return null;
	}

	@Override
	public BlockPos findSpawn(int posX, int posZ, boolean checkValid) {
		return null;
	}

	@Override
	public float calculateCelestialAngle(long worldTime, float partialTicks) {
		double d0 = MathHelper.frac((double) worldTime / 24000.0D - 0.25D);
		double d1 = 0.5D - Math.cos(d0 * Math.PI) / 2.0D;
		return (float) (d0 * 2.0D + d1) / 3.0F;
	}

	@Override
	public boolean doesXZShowFog(int x, int z) {
		return false;
	}

	@Override
	public Vec3d getFogColor(float celestialAngle, float partialTicks) {
//		return Vec3d.fromPitchYaw(FogColor.RED);
		float f = MathHelper.cos(celestialAngle * ((float) Math.PI * 2F)) * 2.0F + 0.5F;
		f = MathHelper.clamp(f, 0.0F, 1.0F);
		float f1 = 0.7529412F;
		float f2 = 0.84705883F;
		float f3 = 1.0F;
		f1 = f1 * (f * 0.94F + 0.06F);
		f2 = f2 * (f * 0.94F + 0.06F);
		f3 = f3 * (f * 0.91F + 0.09F);
		return new Vec3d((double) f1, (double) f2, (double) f3);
	}
	
	@Override
	public IRenderHandler getCloudRenderer() {
		return super.getCloudRenderer();
	}
	
	@Override
	public IRenderHandler getSkyRenderer() {
		return super.getSkyRenderer();
	}
	
	@Override
	public IRenderHandler getWeatherRenderer() {
		return super.getWeatherRenderer();
	}

}
